export default function (data) {
    let cols = [];
    let rows = [];
    let returnJson = {};
    data.columns.forEach((item) => {
        let colsItem = {};
        console.log(item)
        colsItem["title"] = item.columnName;
        colsItem["field"] = item.columnId;
        colsItem["align"] = "center";
        // colsItem["sort"] = true;
        // colsItem["path"] = "1234";
        if (item.sort) {
            colsItem["sort"] = item.sort;
        }
        if (item.columnId !== 'id') {
            cols.push(colsItem);
        }
    })
    if (data.rows) {
        data.rows.forEach((item) => {
            let rowsItem = {};
            for (var key in item.columns) {
                item.columns[key].value = item.columns[key].value ? item.columns[key].value : ''
                if ((item.columns[key].value.indexOf('jpg') !== -1) || (item.columns[key].value.indexOf('png') !== -1)) {
                    let imageArr = item.columns[key].value.split(',');
                    rowsItem[key] = `<img src="${imageArr[0]}" style="width: 40px;height: 40px"/>`;
                } else {
                    rowsItem[key] = item.columns[key].value;
                }
            }
            if (item.operations) {
                for (var key in item.operations) {
                    rowsItem[key] = item.operations[key];
                }
            }
            rows.push(rowsItem)
        });
    }
    returnJson["cols"] = cols;
    returnJson["rows"] = rows;
    return returnJson;
}